package com.bwie.controller;
import com.bwie.pojo.Prod;
import com.bwie.pojo.ProdInfo;
import com.bwie.service.Impl.ProdServiceImpl;
import com.bwie.service.ProdService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* 商品表(tb_prod)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/prod/prod")
public class ProdController {
/**
* 服务对象
*/
    @Autowired
    private ProdService prodService;

    /**
     * 商品列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping(value = "/getProdList")
    public R getProdList(
            @RequestBody PageInfoVo pageInfoVo
            ){
        return prodService.getProdList(pageInfoVo);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @PostMapping(value = "deleteProdBatch")
    public R deleteProdBatch(
            @RequestBody List<Integer> ids
            ){
        return prodService.deleteProdBatch(ids);
    }

    /**
     * 添加商品
     * @param prod
     * @return
     */
    @PostMapping(value = "addProdList")
    public R addProdList(
        @RequestBody Prod prod
    ){
        return prodService.addProdList(prod);
    }

    /**
     * 查询商品信息
     * @param prodId
     * @return
     */
    @PostMapping(value = "selectProdDetail/{prodId}")
    public R selectProdDetail(@PathVariable(name = "prodId") Integer prodId){
        return prodService.selectProdDetail(prodId);
    }

    /**
     * 商品详情列表
     * @return
     */
    @PostMapping(value = "selectProdInfo")
    public R selectProdInfo(){
        return prodService.selectProdInfo();
    }

    /**
     * 添加商品详情
     * @param prodInfo
     * @return
     */
    @PostMapping(value = "/addProdInfo")
    public R addProdInfo(@RequestBody ProdInfo prodInfo){
        return prodService.addProdInfo(prodInfo);
    }

    /**
     * 根据商品查询订单详情详情
     * @param prodId
     * @param pageInfoVo
     * @return
     */
    @PostMapping(value = "/selectProdInfoByProdId/{prodId}")
    public R selectProdInfoByProdId(@PathVariable(name = "prodId")Integer prodId, @RequestBody PageInfoVo pageInfoVo){
        return prodService.selectProdInfoByProdId(prodId,pageInfoVo);
    }
}
